/*
 * Decompiled with CFR 0.150.
 * 
 * Could not load the following classes:
 *  cn.hutool.core.util.StrUtil
 *  com.alibaba.fastjson.JSON
 *  de.felixroske.jfxsupport.FXMLController
 *  javafx.fxml.FXML
 *  javafx.fxml.Initializable
 *  javafx.scene.control.Alert
 *  javafx.scene.control.Alert$AlertType
 *  javafx.scene.control.CheckBox
 *  javafx.scene.control.ScrollPane
 *  javafx.scene.control.TextField
 *  javafx.scene.layout.AnchorPane
 *  javafx.scene.layout.VBox
 */
package com.gys.controller.rechargecard;

import cn.hutool.core.util.StrUtil;
import com.alibaba.fastjson.JSON;
import com.gys.common.business.RechargeCardUtil;
import com.gys.common.data.HttpJson;
import com.gys.common.util.ValidationUtil;
import com.gys.controller.BaseController;
import com.gys.data.rechargecard.RechargeCardSetInData;
import com.gys.data.rechargecard.RechargeCardSetOutData;
import de.felixroske.jfxsupport.FXMLController;
import java.net.URL;
import java.util.ResourceBundle;
import javafx.fxml.FXML;
import javafx.fxml.Initializable;
import javafx.scene.control.Alert;
import javafx.scene.control.CheckBox;
import javafx.scene.control.ScrollPane;
import javafx.scene.control.TextField;
import javafx.scene.layout.AnchorPane;
import javafx.scene.layout.VBox;

@FXMLController
public class RechargeCardSetController
extends BaseController
implements Initializable {
    @FXML
    private AnchorPane anchorPane;
    @FXML
    private ScrollPane scrollPane;
    @FXML
    private VBox vBox;
    @FXML
    private TextField cardPrefixSave;
    @FXML
    private TextField passwordSave;
    @FXML
    private TextField paymentMethodSave;
    @FXML
    private CheckBox pwNeedOptSave;
    @FXML
    private CheckBox minAmtOpt;
    @FXML
    private CheckBox maxAmtOptSave;
    @FXML
    private CheckBox firstPwOptSave;
    @FXML
    private CheckBox recoverpwOptSave;
    @FXML
    private TextField proportion1Save;
    @FXML
    private TextField minAmt1Save;
    @FXML
    private TextField proportion2Save;
    @FXML
    private TextField proportion3Save;
    @FXML
    private TextField minAmt2Save;
    @FXML
    private TextField minAmt3Save;
    @FXML
    private CheckBox promotion2Save;
    @FXML
    private CheckBox repeat2Save;
    @FXML
    private CheckBox promotion3save;
    @FXML
    private CheckBox repeat3Save;

    public void initialize(URL location, ResourceBundle resources) {
        this.loadSetData();
        this.scrollPane.setPrefWidth(this.getContentWidth());
        this.scrollPane.setPrefHeight(this.getContentHeight());
        this.vBox.setPrefWidth(this.getContentWidth());
        this.vBox.setPrefHeight(this.getContentHeight());
    }

    @FXML
    private void saveCardSet() {
        Alert alert = this.createAlert(Alert.AlertType.INFORMATION, "\u63d0\u793a\u4fe1\u606f", null);
        if (this.cardPrefixSave.getText().length() > 5) {
            alert.setContentText("\u50a8\u503c\u5361\u524d\u7f00\u957f\u5ea6\u4e0d\u8d85\u8fc75\u4f4d");
            alert.showAndWait();
            return;
        }
        if (!ValidationUtil.checkNumberOrChar(this.cardPrefixSave.getText())) {
            alert.setContentText("\u50a8\u503c\u5361\u524d\u7f00\u53ea\u80fd\u662f\u6570\u5b57\u6216\u8005\u5b57\u6bcd\u7ec4\u5408");
            alert.showAndWait();
            return;
        }
        if (StrUtil.isBlank((CharSequence)this.passwordSave.getText())) {
            alert.setContentText("\u521d\u59cb\u5bc6\u7801\u4e0d\u80fd\u4e3a\u7a7a");
            alert.showAndWait();
            return;
        }
        if (!ValidationUtil.checkNumberStr(this.passwordSave.getText())) {
            alert.setContentText("\u521d\u59cb\u5bc6\u7801\u4e3a6\u4f4d\u6570\u5b57");
            alert.showAndWait();
            return;
        }
        if (this.passwordSave.getText().length() != 6) {
            alert.setContentText("\u521d\u59cb\u5bc6\u7801\u4e3a6\u4f4d\u6570\u5b57");
            alert.showAndWait();
            return;
        }
        if (StrUtil.isBlank((CharSequence)this.paymentMethodSave.getText())) {
            alert.setContentText("\u652f\u4ed8\u65b9\u5f0f\u4e0d\u80fd\u4e3a\u7a7a");
            alert.showAndWait();
            return;
        }
        if (this.paymentMethodSave.getText().length() > 10) {
            alert.setContentText("\u652f\u4ed8\u65b9\u5f0f\u957f\u5ea6\u4e0d\u8d85\u8fc710\u4f4d");
            alert.showAndWait();
            return;
        }
        if (!ValidationUtil.checkPositiveInteger(this.proportion2Save.getText())) {
            alert.setContentText("\u6bd4\u4f8b2\u4e0d\u662f\u6b63\u6574\u6570");
            alert.showAndWait();
            return;
        }
        if (!ValidationUtil.checkAmount(this.minAmt2Save.getText())) {
            alert.setContentText("\u6bd4\u4f8b2\u8d77\u5145\u91d1\u989d\u4e0d\u5408\u6cd5");
            alert.showAndWait();
            return;
        }
        if (!ValidationUtil.checkPositiveInteger(this.proportion3Save.getText())) {
            alert.setContentText("\u6bd4\u4f8b3\u4e0d\u662f\u6b63\u6574\u6570");
            alert.showAndWait();
            return;
        }
        if (!ValidationUtil.checkAmount(this.minAmt3Save.getText())) {
            alert.setContentText("\u6bd4\u4f8b3\u8d77\u5145\u91d1\u989d\u4e0d\u5408\u6cd5");
            alert.showAndWait();
            return;
        }
        RechargeCardSetInData inData = new RechargeCardSetInData();
        inData.setGsrcsCardPrefix(this.cardPrefixSave.getText());
        inData.setGsrcsPassword(this.passwordSave.getText());
        inData.setGsrcsPaymentMethod(this.paymentMethodSave.getText());
        inData.setGsrcsPwNeedOpt(this.firstPwOptSave.isSelected() ? "1" : "0");
        inData.setGsrcsMinAmtOpt(this.minAmtOpt.isSelected() ? "1" : "0");
        inData.setGsrcsMaxAmtOpt(this.maxAmtOptSave.isSelected() ? "1" : "0");
        inData.setGsrcsFirstPwOpt(this.firstPwOptSave.isSelected() ? "1" : "0");
        inData.setGsrcsRecoverpwOpt(this.recoverpwOptSave.isSelected() ? "1" : "0");
        inData.setGsrcsProportion1(this.proportion1Save.getText());
        inData.setGsrcsMinAmt1(this.minAmt1Save.getText());
        inData.setGsrcsProportion2(this.proportion2Save.getText());
        inData.setGsrcsMinAmt2(this.minAmt2Save.getText());
        inData.setGsrcsPromotion2(this.promotion2Save.isSelected() ? "1" : "0");
        inData.setGsrcsRepeat2(this.repeat2Save.isSelected() ? "1" : "0");
        inData.setGsrcsProportion3(this.proportion3Save.getText());
        inData.setGsrcsMinAmt3(this.minAmt3Save.getText());
        inData.setGsrcsPromotion3(this.promotion3save.isSelected() ? "1" : "0");
        inData.setGsrcsRepeat3(this.repeat3Save.isSelected() ? "1" : "0");
        HttpJson rsp = RechargeCardUtil.saveCardSet(inData);
        if (rsp.isSuccess()) {
            alert.setContentText("\u50a8\u503c\u5361\u8bbe\u7f6e\u4fdd\u5b58\u6210\u529f");
            alert.showAndWait();
        } else {
            alert.setContentText(rsp.getMsg());
            alert.showAndWait();
        }
    }

    private void loadSetData() {
        HttpJson res = RechargeCardUtil.getSetData();
        if (res.isSuccess()) {
            RechargeCardSetOutData outData = (RechargeCardSetOutData)JSON.parseObject((String)res.getMsg(), RechargeCardSetOutData.class);
            this.cardPrefixSave.setText(outData.getGsrcsCardPrefix());
            if (StrUtil.isBlank((CharSequence)outData.getGsrcsPassword())) {
                outData.setGsrcsPassword("123456");
            }
            this.passwordSave.setText(outData.getGsrcsPassword());
            if (StrUtil.isBlank((CharSequence)outData.getGsrcsPaymentMethod())) {
                outData.setGsrcsPaymentMethod("\u50a8\u503c\u5361");
            }
            this.paymentMethodSave.setText(outData.getGsrcsPaymentMethod());
            if (StrUtil.isBlank((CharSequence)outData.getGsrcsPwNeedOpt())) {
                outData.setGsrcsPwNeedOpt("1");
            }
            this.pwNeedOptSave.setSelected(StrUtil.equals((CharSequence)"1", (CharSequence)outData.getGsrcsPwNeedOpt()));
            if (StrUtil.isBlank((CharSequence)outData.getGsrcsMinAmtOpt())) {
                outData.setGsrcsMinAmtOpt("1");
            }
            this.minAmtOpt.setSelected(StrUtil.equals((CharSequence)"1", (CharSequence)outData.getGsrcsMinAmtOpt()));
            if (StrUtil.isBlank((CharSequence)outData.getGsrcsMaxAmtOpt())) {
                outData.setGsrcsMaxAmtOpt("1");
            }
            this.maxAmtOptSave.setSelected(StrUtil.equals((CharSequence)"1", (CharSequence)outData.getGsrcsMaxAmtOpt()));
            if (StrUtil.isBlank((CharSequence)outData.getGsrcsFirstPwOpt())) {
                outData.setGsrcsFirstPwOpt("1");
            }
            this.firstPwOptSave.setSelected(StrUtil.equals((CharSequence)"1", (CharSequence)outData.getGsrcsFirstPwOpt()));
            this.recoverpwOptSave.setSelected(StrUtil.equals((CharSequence)"1", (CharSequence)outData.getGsrcsRecoverpwOpt()));
            if (StrUtil.isBlank((CharSequence)outData.getGsrcsProportion1())) {
                outData.setGsrcsProportion1("100");
            }
            this.proportion1Save.setText(outData.getGsrcsProportion1());
            if (StrUtil.isBlank((CharSequence)outData.getGsrcsMinAmt1())) {
                outData.setGsrcsMinAmt1("1");
            }
            this.minAmt1Save.setText(outData.getGsrcsMinAmt1());
            this.proportion2Save.setText(outData.getGsrcsProportion2());
            this.proportion3Save.setText(outData.getGsrcsProportion3());
            this.minAmt2Save.setText(outData.getGsrcsMinAmt2());
            this.minAmt3Save.setText(outData.getGsrcsMinAmt3());
            this.promotion2Save.setSelected(StrUtil.equals((CharSequence)"1", (CharSequence)outData.getGsrcsPromotion2()));
            this.repeat2Save.setSelected(StrUtil.equals((CharSequence)"1", (CharSequence)outData.getGsrcsRepeat2()));
            this.promotion3save.setSelected(StrUtil.equals((CharSequence)"1", (CharSequence)outData.getGsrcsPromotion3()));
            this.repeat3Save.setSelected(StrUtil.equals((CharSequence)"1", (CharSequence)outData.getGsrcsRepeat3()));
        } else {
            Alert alert = this.createAlert(Alert.AlertType.INFORMATION, "\u63d0\u793a\u4fe1\u606f", null);
            alert.setContentText(res.getMsg());
            alert.showAndWait();
        }
    }
}

